
#import "privateJSONParser.h"

@implementation privateJSONDParser

-(id)initWithObjectAndDic:(NSString*)str withDic:(NSMutableDictionary*)dic
{
    self = [super init];
	if (self)
	{
        NSMutableString * tempStr = [NSMutableString stringWithString:str];
        [tempStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [str length])];
        [tempStr replaceOccurrencesOfString:@" " withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [str length])];
        m_str = tempStr;
        m_dic = dic;
	}
	return self;
}

-(id)init
{
    self =[super init];
    if(self)
    {
        
    }
    return self;
}

-(NSString*)parseObject:(NSString*)str
{
    NSRange range = [m_str rangeOfString:str];
    if(range.location == NSNotFound || range.location >= [m_str length])
        return nil;
    NSString * sub = [m_str substringFromIndex:range.location + range.length + 2];
    if(sub != nil)
    {
        NSRange range2 = [sub rangeOfString:@"\","];
        range.location = 1;
        range.length = range2.location;
        
        if(range.length > [sub length])
        {
            return nil;
        }
        
        sub = [sub substringWithRange:range];
        if(sub != nil)
            [m_dic setObject:sub forKey:str];
    }
    
    return sub;
}

@end